//
//  PhotoViewController.m
//  Feeds2
//
//  Created by cos on 2020/12/3.
//  Copyright © 2020 cos. All rights reserved.
//

#import "PhotoViewController.h"
  
@interface PhotoViewController ()
  
@end
  
@implementation PhotoViewController
  
- (void)viewDidLoad {
  [super viewDidLoad];
    
    UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    
  myScrollView.backgroundColor = [UIColor blackColor];
  myScrollView.pagingEnabled = YES;
  myScrollView.bounces = NO;
    
  [self.view addSubview:myScrollView];
  //根据tag 来获取当前点击的图片
  myScrollView.contentOffset = CGPointMake(self.view.frame.size.width * self.imageTag, 10);
    
  myScrollView.contentSize = CGSizeMake(self.view.frame.size.width * self.photoArr.count, 667);
  //创建
  for (int i = 0; i < self.photoArr.count; i++)
  {
    UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width * i + 10, 0, self.view.frame.size.width - 20, self.view.frame.size.height)];
    //NSString *imgName = self.photoArr[i];
    //img.image = [UIImage imageNamed:imgName];
      img.image = self.photoArr[i];
    [myScrollView addSubview:img];
      
    //自适应图片大小
    img.contentMode = UIViewContentModeScaleAspectFit;
      
  }
    
  //轻拍跳出照片浏览
  UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    
  [myScrollView addGestureRecognizer:tap];
  
}
  
- (void)tapAction
{
  [self dismissViewControllerAnimated:YES completion:^{
      
      
  }];
}
  
- (void)didReceiveMemoryWarning {
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}
  
/*
#pragma mark - Navigation
  
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  // Get the new view controller using [segue destinationViewController].
  // Pass the selected object to the new view controller.
}
*/
  
@end

